<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style></style>
</head>

<body>
<input type="text" id="d1" placeholder="请输入手机号" > <br>
<input type="text" id="d2" placeholder="请输入验证码">  <br>
<input type="text" id="d3" placeholder="请输入密码">
<button id="btn" >注册</button>

<script>
//获取元素
var inp1=document.getElementById('d1');
var inp2=document.getElementById('d2');
var  inp3=document.getElementById('d3');
//点击按钮事件
btn.onclick=function (){
  var phone=inp1.value;
  var vcode=inp2.value;
  var pwd=inp3.value;
//创建对象
var xhr=new XMLHttpRequest();
//监听并接收响应体
xhr.onreadystatechange=function (){
   if(xhr.readyState==4){
     if(xhr.status>=200 && xhr.status<300){
          var result=xhr.responseText;
          console.log(result);
         var obj= JSON.parse(result);
         alert(obj.msg);

     }else{
        console.log('返回其他状态码');
     }

   }

}
//设置请求信息
xhr.open('POST','/reg',true);
//发送
xhr.send('');

}

</script>

</body>

</html>